<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ page import="com.smarthome.web.property.utils.PermissionUtil"  %>

<%
String path = request.getContextPath(); 
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="${path}/views/layout/inc.jsp"></jsp:include>
<script type="text/javascript" src="${path}/js/system/account.js" ></script>
<script type="text/javascript">
	$.canEdit = true;
	$.canDelete = true;
	$.canChangeHouse=true;
	var dataGrid;
	$(function(){
		//加载小区、楼栋、单元、门牌等信息
		loadResidence('');
		var isAdmin = ${isAdmin};
		if(!isAdmin){
			$("#residenceId").combobox("select","${residenceId}");
			$("#residenceId").combobox("disable");
		}
		
		dataGrid=$("#dataGrid").datagrid({
			url:"/accountDoor/dataGrid?status=2&accountId=${account.id}",
			width:'100%',
			nowrap: false,
			striped: true,
			fit:true,
			collapsible:true,
			pageNumber:1,
			pageSize:10,
			pageList:[10],
			fitColumns:true,
			columns:[[
				{field:'name',title:'用户姓名',width:100},
				{field:'loginName',title:'登录名',width:100},
				{field:'mobile',title:'手机号',width:100},
				{field:'residenceName',title:'小区',width:100},
				{field:'buildingName',title:'楼栋',width:50},
				{field:'unitName',title:'单元',width:50},
				{field:'doorName',title:'门牌',width:50},
				{field:'owner',title:'是否业主',width:80,formatter:function(value, row, index){
					var ok = "<span style='color:green'>是</span>";
					var not = "<span style='color:red'>否</span>";
					return value==1?ok:not;
				}},
				{field:'gmtCreate',title:'新增时间',width:100,sortable:true,formatter : function(value, row, index) {
					var unixTimestamp = new Date(value);  
                    return unixTimestamp.format("yyyy-MM-dd hh:mm:ss");
				}}
			]],
			sortName: 'gmtCreate',
			sortOrder: 'desc',
			checkOnSelect : false,
			selectOnCheck : false,
			pagination:true,
			rownumbers:true,
			singleSelect:true, // 是否单选
			toolbar:"#toolbar",
			onLoadSuccess : function() {
				parent.$.messager.progress('close');
			},
			onRowContextMenu : function(e, index, row){
				e.preventDefault();
				dataGrid.datagrid("unselectAll");
				dataGrid.datagrid("selectRow",index);
				$('#menu').menu('show', {
					left : e.pageX,
					top : e.pageY
				});
			}
		});
	});
	
	
	function searchFun() {
		dataGrid.datagrid('load', $.serializeObject($('#searchForm')));
	}
	function cleanFun() {
		$('#searchForm input').val('');
		dataGrid.datagrid('load', {});
	}
	function checkFun(){
		var row=dataGrid.datagrid("getSelected");
		if(row){
			if(row.status!=2){
				parent.$.messager.alert("提示","该记录不是待审核状态！","info");	
			}else{
				parent.$.messager.confirm('询问', '该用户信息是否正确？', function(b) {
					if(b){
						parent.$.messager.progress({
							title : '提示',
							text : '数据处理中，请稍后....'
						});
						$.post('/accountDoor/checkOk',{'id':row.id},function(result){
							parent.$.messager.progress('close');
							parent.$.messager.alert('提示', result.msg, 'info');
							if (result.success) {
								dataGrid.datagrid('reload');
							}
						},'json');
					}
				});
			}
		}else{
			parent.$.messager.alert("提示","请选择要审核的记录！","info");
		}
	}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>业主</title>
</head>
<body>
	<div class="easyui-layout" data-options="fit:true,border:false">
		<div data-options="region:'north',title:'查询条件',border:false" style="height: 100px; overflow: hidden;">
			<form id="searchForm">
				<table class="table table-hover table-condensed" style="">
					<tr>
						<td>小区</td>
						<td><input id="residenceId" name="residenceId" /></td>
						<td>楼栋</td>
						<td><input id="buildingId" name="buildingId" class="easyui-combobox" panelHeight='auto' /></td>
					</tr>
					<tr>
						<td>单元</td>
						<td><input id="unitId" name="unitId" class="easyui-combobox" panelHeight='auto' /></td>
						<td>门牌</td>
						<td><input id="doorId" name="doorId" class="easyui-combobox" panelHeight='auto' /></td>
					</tr>
<!-- 					<tr> -->
<!-- 						<td>用户状态</td> -->
<!-- 						<td><input id="status" name="status" class="easyui-combobox" panelHeight='auto' /></td> -->
<!-- 						<td>手机号</td> -->
<!-- 						<td><input id="mobile" name="mobile" class="easyui-validatebox" /></td> -->
<!-- 					</tr> -->
<!-- 					<tr> -->
<!-- 						<td>用户姓名</td> -->
<!-- 						<td><input id="name" name="name" class="easyui-validatebox" /></td> -->
<!-- 						<td>登录名</td> -->
<!-- 						<td><input id="loginName" name="loginName" class="easyui-validatebox" /></td> -->
<!-- 					</tr> -->
				</table>
			</form>
		</div>
		<div data-options="region:'center',border:false" title="" style="overflow: hidden;">
			<table id="dataGrid"> </table>
		</div>
		<div id="toolbar" style="display: none;">
				<a onclick="checkFun();" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">审核通过</a>
				<a onclick="searchFun();" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">提交查询</a>
				<a onclick="cleanFun();" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-reload'">重置查询</a>
		</div>
	</div>
	<div id="menu" class="easyui-menu" style="width: 120px; display: none;">
	</div>
</body>
</html>